package com.sz.jinzheng.controller;

import com.sz.jinzheng.client.UserCilent;
import com.sz.jinzheng.model.Result;
import com.sz.jinzheng.model.StaffExmination;
import com.sz.jinzheng.model.Task;
import com.sz.jinzheng.service.ManagerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author qin
 * @version 1.0
 * @description: TODO
 * @date 2021/7/21 19:23
 */
@Slf4j
@RestController
@RequestMapping("/manager")
public class ManagerController {
    @Autowired
    private ManagerService managerService;
    @Autowired
    private UserCilent userCilent;

    //通过任务id查询审查专员审查记录
    @RequestMapping("/getReviewByTid")
    public Result getReviewByTid(@RequestBody Task task,Integer borrowerInfoId){
        //通过token拿到uid
        Integer uid = userCilent.getUid(task.getToken());
        task.setUserId(uid);
        log.info("task=" + task);

        List<StaffExmination> reviewList = managerService.getReviewByTid(task);
        return new Result(200,"查询审查专员审查记录成功",reviewList);
    }

    //添加审查记录
    @RequestMapping("/insertReviewRecord")
    public Result insertReviewRecord(@RequestBody StaffExmination staffExmination){
        int i = managerService.insertReviewRecord(staffExmination);
        if (i>0){
            return new Result(200,"业务经理审批完成");
        }
        return null;
    }
}
